﻿/*
 * Created by SharpDevelop.
 * User: 김효순
 * Date: 2012-09-04
 * Time: 오후 12:09
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace 스크린
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		private const int ABM_GETTASKBARPOS = 0x5;
		
		private struct RECT {
			public int Left;
		    public int Top;
		    public int Right;
		    public int tBottom;
		}
		
		private struct APPBARDATA
		{
		    public int cbSize;
		    public IntPtr hWnd;
		    public int uCallbackMessage;
		    public int uEdge;
		    public RECT rc;
		    public IntPtr lParam;
		}
		
		[DllImport("shell32.dll")]
		private static extern int SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
		
		private APPBARDATA ABD;

		
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		void Bt1Click(object sender, EventArgs e)
		{
			string szOut = "";

			foreach (var screen in System.Windows.Forms.Screen.AllScreens)
		    {
		        szOut += "Device Name: " + screen.DeviceName + "\r\n";
		        szOut += "Bounds: " + screen.Bounds.ToString() + "\r\n";
		        szOut += "Type: " + screen.GetType().ToString() + "\r\n";
		        szOut += "Working Area: " + screen.WorkingArea.ToString() + "\r\n";
		        szOut += "Primary Screen: " + screen.Primary.ToString() + "\r\n";
		    }

			tbResult.Text = szOut;			
		}
		
		void Bt2Click(object sender, EventArgs e)
		{
			string szOut = "";
			
			ABD.cbSize = Marshal.SizeOf(ABD);
			SHAppBarMessage(ABM_GETTASKBARPOS, ref ABD);
			
			szOut = "left: " + ABD.rc.Left.ToString() + "\r\ntop: " + ABD.rc.Top.ToString() + "\r\nright: " + ABD.rc.Right.ToString() + "\r\nbottom: " + ABD.rc.tBottom.ToString();
			tbResult.Text = szOut;
		}
	}
}
